<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Symbol Iterator</title>
</head>

<body>
    <script>
        let obj = {
            a: 10,
            b: 20,
            [Symbol.iterator]: function (e, f, g) {
                return {
                    next: function (a, b, c) {
                        return {
                            done: true,
                            value: 1
                        }
                    }
                }
            }
        }
        for (let x of obj) {
            console.log(x);
        }
    </script>

    <script>
        let arr = ['a', 'b', 'c'];
        let iterator = arr[Symbol.iterator]();
        console.log(iterator.next());
        console.log(iterator.next());
        console.log(iterator.next());
        console.log(iterator.next());
    </script>
</body>

</html>